package edu.sctu.jarime.june.day20150628.util;

import edu.sctu.jarime.june.day20150628.appbean.JsonAppbean;


/**
 * Created by user19 on 2015/6/28.
 */
public class JudgeUtil {

    JsonAppbean jsonAppbean;

    public JudgeUtil(JsonAppbean jsonAppbean){

        this.jsonAppbean=jsonAppbean;
    }

    /***
     * 计算价格超过100的商品个数
     * @return
     */
    public int priceOverHundred(){

        int count=0;
        for (int i = 0; i <jsonAppbean.list.size() ; i++) {
            double price =Double.parseDouble(jsonAppbean.list.get(i).goods_price);
           if (price>100){
               count++;
           }
        }
        return count;
    }

    /***
     * 计算商品价格低于100的个数
     * @return
     */
    public int priceBelowHundred(){

        int count=0;
        for (int i = 0; i <jsonAppbean.list.size() ; i++) {
            double price =Double.parseDouble(jsonAppbean.list.get(i).goods_price);
            if (price<100){
                count++;
            }
        }

        return count;
    }
}
